//
//  MyMessageDetailViewController.m
//  eshow
//
//  Created by Hisoka on 15/12/25.
//  Copyright © 2015年 Hisoka. All rights reserved.
//

#import "MyMessageDetailViewController.h"

@interface MyMessageDetailViewController ()<UIWebViewDelegate>

@property (nonatomic, strong) UIWebView *webView;
@property (nonatomic, strong) UITextView *textView;

@end

@implementation MyMessageDetailViewController

- (void) viewWillDisappear:(BOOL)animated {
    [SVProgressHUD dismiss];
}

- (void)viewDidLoad {
    [super viewDidLoad];
    [self customizeBackItem];
    self.navigationController.interactivePopGestureRecognizer.delegate = nil;
    self.automaticallyAdjustsScrollViewInsets = NO;
    self.navigationItem.title = @"消息详情";
    
    if ([_isWebView isEqualToString:@"1"]) {
        [self setWebViewStyle];
    }else{
        [self setTextViewStyle];
    }
}

#pragma mark - 设置webview样式
- (void) setWebViewStyle {

    self.view.backgroundColor = WHITE_COLOR;
    
    self.webView = [[UIWebView alloc] initForAutoLayout];
    [self.view addSubview:_webView];
    
    [_webView autoPinToTopLayoutGuideOfViewController:self withInset:0];
    [_webView autoPinEdge:ALEdgeLeft toEdge:ALEdgeLeft ofView:self.view];
    [_webView autoPinEdge:ALEdgeRight toEdge:ALEdgeRight ofView:self.view];
    [_webView autoPinEdge:ALEdgeBottom toEdge:ALEdgeBottom ofView:self.view];
    
    _webView.delegate = self;
    
    NSURLRequest *request = [NSURLRequest requestWithURL:[NSURL URLWithString:_reqUrl]];
    
    [_webView loadRequest:request];
    
    
    [SVProgressHUD show];
    [self performSelector:@selector(dismissSVHUD) withObject:nil afterDelay:1.5f];
}

#pragma mark - 设置textview样式
- (void) setTextViewStyle {
    self.view.backgroundColor = WHITE_COLOR;
    
    self.textView = [UITextView newAutoLayoutView];
    [self.view addSubview:_textView];
    
    [_textView autoPinToTopLayoutGuideOfViewController:self withInset:10];
    [_textView autoPinEdge:ALEdgeLeft toEdge:ALEdgeLeft ofView:self.view withOffset:10];
    [_textView autoPinEdge:ALEdgeRight toEdge:ALEdgeRight ofView:self.view withOffset:10];
    [_textView autoPinEdge:ALEdgeBottom toEdge:ALEdgeBottom ofView:self.view withOffset:10];
    
    _textView.editable = NO;
    _textView.font = FONT_SIZE_18;
    _textView.text = _contentStr;
}

- (void) dismissSVHUD {
    [SVProgressHUD dismiss];
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
